package spring.springsecurety.Config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.NoOpPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.oauth2.provider.client.JdbcClientDetailsService;

import javax.annotation.Resource;
import javax.sql.DataSource;

@Configuration
public class ClientDetailsServiceZhang {


    @Resource
    private DataSource dataSource;

    @Bean
    public PasswordEncoder passwordEncoder(){

        return new BCryptPasswordEncoder();
    }

    @Bean
    public JdbcClientDetailsService JdbcClientDetailsService(){
        JdbcClientDetailsService service=new JdbcClientDetailsService(dataSource);
        service.setPasswordEncoder(passwordEncoder());
        return service;
    }
}
